package com.ferry.registry.domain.service;
import	java.io.Serializable;

import java.util.Objects;

/**
 * Created by daiyong
 */
public class ServiceMetaData implements Serializable {

	private static final long serialVersionUID = -6851796101475151457L;

	private String group;
	private String serviceName;
	private String version;

	public ServiceMetaData(String group, String serviceName, String version) {
		this.group = group;
		this.serviceName = serviceName;
		this.version = version;
	}

	public String getGroup() {
		return group;
	}

	public void setGroup(String group) {
		this.group = group;
	}

	public String getServiceName() {
		return serviceName;
	}

	public void setServiceName(String serviceName) {
		this.serviceName = serviceName;
	}

	public String getVersion() {
		return version;
	}

	public void setVersion(String version) {
		this.version = version;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		ServiceMetaData that = (ServiceMetaData) o;
		return Objects.equals(group, that.group) &&
				Objects.equals(serviceName, that.serviceName) &&
				Objects.equals(version, that.version);
	}

	@Override
	public int hashCode() {
		return Objects.hash(group, serviceName, version);
	}

	public String directoryString() {
		StringBuilder buf = new StringBuilder();
		buf.append(getGroup())
				.append('-')
				.append(getServiceName())
				.append('-')
				.append(getVersion());
		return buf.toString();
	}
}
